<div class="user-accounts-my-ads">
                    <div class="my-ads-select-all">
            	<div class="select-all-options">
                  <input type="hidden" id="checkstatus" value="1">
                	<div id="selectall" class="select-all-link" style="color:#0000ff;cursor:pointer" onclick="check();">
                      Select All
                    </div>
                    <div class="my-ads-delete">
                    	<%= link_to image_tag("select-all-delete.jpg", :width=>"54", :height=>"21", :border=>"0") %>
                    </div>
                    <div class="my-ads-delete">
                      <%= link_to_remote  image_tag("select-all-renew.jpg", :width=>"54", :height=>"21", :border=>"0")%>
                    </div>
                    
                </div>
                <div class="my-ads-pages">
                	
                   
                    	<%= will_paginate(@user_advertisments)%>
                    
                </div>
            </div>
            <div class="table-header">
            	<div class="table-header-ad">
                	Ad
                </div>
                <div class="table-header-responses">
                	Responses <%= image_tag "sort-arrow.png", :width=>"6", :height=>"6", :border=>"0"  %>
                </div>
                <div class="table-header-relevant">
                	Relevant Ads <%= image_tag "sort-arrow.png", :width=>"6", :height=>"6", :border=>"0"  %>
                </div>
                <div class="table-header-action">
                	Actions
                </div>
            </div>


  <% form_for :advertisments, :url => {:controller=>"advertisments", :action => "edit_ad" , :id => params[:id] } do |adform| %>
        <%@user_advertisments.each do |advertisment| -%>
          <div class="my-ads-listing" id="my-ads-listings-<%=advertisment.id%>">
            	<div class="my-ads-details">
                	<div class="my-ads-checkbox">
                      <input type="checkbox" name="my_ad" id="my_ad_<%= advertisment.id %>" value="<%= advertisment.id %>" /><br>
                    </div>
                    <div id="my-ads-details-fields" class="my-ads-details-fields">
                    	<div class="my-ads-ad-title">
                          	<%#=link_to_remote "Edit", :url=>{:action => "edit_ad",:controller=>"login", :id => advertisment.id},:update=>"user-accounts-dashboard",:method=>"GET" -%>
                        	<%=link_to_remote advertisment.title, :url=>{:controller=>"login", :action=>"show_advertisment", :id=>advertisment.id} ,:update=>"user-accounts-dashboard",:method=>"GET" -%>
                        </div>
                        <div class="my-ads-posted-in">
                        	<div class="my-ads-posted-text">
                            	Posted in:
                        	</div>
                            <div class="my-ads-posted-value">
                            	<%= University.find(advertisment.university_id).name %>
                            </div>
                        </div>
                        <div class="my-ads-posted-in">
                        	<div class="my-ads-posted-text">
                            	Posted on:
                        	</div>
                            <div class="my-ads-posted-value">
                            	<%= advertisment.created_at.to_formatted_s(:long_ordinal) %>
                            </div>
                        </div>
                         <%
                                  @sub_category_id        = advertisment.sub_category_id
                                  @sub_category_lifespan  = SubCategory.find(@sub_category_id).lifespan
                                  @category               = SubCategory.find(@sub_category_id).category_id
                              %>

                       <%if @category!=2%>
                        <div class="my-ads-posted-in">
                        	<div class="my-ads-posted-text">
                            	Expires on:
                        	</div>
                            <div class="my-ads-posted-value">

                              <%  @expires= advertisment.created_at + @sub_category_lifespan.days -%>
                              <%= @expires.to_formatted_s(:long_ordinal) %>
                            </div>
                        </div>
                       <%end-%>
                    </div>
                    <div class="my-ads-responses">
                    	<a href=""><%= @count=Query.count(:conditions=>"advertisment_id="+advertisment.id.to_s,:order=>"created_at desc")-%></a>
                    </div>
                    <div class="my-ads-responses">
                    	<a href="">         <%count=0%>
                            <%@subcategory_id=advertisment.sub_category_id -%>
                            <%@category_id=SubCategory.find(@subcategory_id).category_id-%>
                            <%@group_id=Category.find(@category_id).group_id-%>
                            <%@opposite_category_ids=Category.find(:all,:conditions=>"id!="+@category_id.to_s+ " and group_id="+@group_id.to_s)-%>
                                <%@opposite_category_ids.each do |category| -%>
                                <%@opposite_subcategory_ids=SubCategory.find(:all,:conditions=>"category_id="+category.id.to_s)-%>
                                <%@opposite_subcategory_ids.each do |subcategory| -%>


                                <%count=count+Advertisment.count(:conditions=>"sub_category_id = "+subcategory.id.to_s,:order =>"created_at DESC")%>

                                <%end -%>
                            <%end -%>

 <%=count%>
</a>
                    </div>
                    <div class="my-ads-actions">
                    	<div class="ad-edit">
                        	<div class="ad-edit-button">
                              <%=link_to_remote image_tag("edit-ad.png",:border=>0), :url=>{:action => "edit_ad",:controller=>"login", :id => advertisment.id}, :update=>"my-ads-listings-"+advertisment.id.to_s,:method=>"GET" -%>
                            </div>
                            <div class="ad-edit-link">
                            	<%=link_to_remote "Edit", :url=>{:action => "edit_ad",:controller=>"login", :id => advertisment.id},:update=>"user-accounts-dashboard",:method=>"GET" -%>
                            </div>
                        </div>
                                            	<div class="ad-edit">
                        	<div class="ad-edit-button">
                              <%=link_to image_tag("delete-ad.png",:border=>0), :advertisment=>advertisment.id, :action=>"delete_advertisment"%>
                            </div>
                            <div class="ad-edit-link">
                              <%= link_to "Delete", :advertisment=>advertisment.id, :action=>"delete_advertisment"%>
                            </div>
                        </div>
                                            	<div class="ad-edit">
                        	<div class="ad-edit-button">
                              <%=link_to image_tag("renew-ad.png",:border=>0)%>
                            </div>
                            <div class="ad-edit-link">
                            <%= link_to_remote  "Renew",:url=>{:controller=>"login", :action=>"renew_advertisment",:id=>advertisment.id.to_s}, :update=>"user-accounts-dashboard" %>

                            </div>
                        </div>
                                            	
                    </div>
                </div>
            </div>

      <%end -%>
  <%end -%>




        </div>
